package cbfz;
import java.sql.*;
public class RecordSet {
	public static ResultSet getRs(Connection con,String sql){
		ResultSet rs = null;
		try{
		Statement st=con.createStatement();
		rs=st.executeQuery(sql);
		}
		catch(SQLException e){
			e.printStackTrace();
		}
		return rs;
	}
	public ResultSet getDatabasesName(Connection con) throws SQLException{
		DatabaseMetaData metaData = con.getMetaData();
		ResultSet rs= metaData.getCatalogs();
		while (rs.next())
			{
				System.out.println(rs.getString("TABLE_CAT"));
			}
		return rs;
	}
	public ResultSet getTablesName(Connection con) throws SQLException{
		DatabaseMetaData metaData = con.getMetaData();
		ResultSet rs = metaData.getTables(con.getCatalog(), null, null, new String[]{"TABLE"});
	    while (rs.next()) {
	        System.out.println(rs.getString("TABLE_NAME"));
	    }
		return rs;
	}
	public  void NoreturnSQL(Connection con,String sql){
		try{
			Statement st=con.createStatement();
			st.executeUpdate(sql);
			}
			catch(SQLException e){
				e.printStackTrace();
			}
	}
	public static void main(String[] args) {
		
	}

}
